home *** CD-ROM | disk | FTP | other *** search
- /*
- File: DAM_StdCommands.h
-
- Contains: All builder routines for SCSI CDBs.
-
- Version: 1.0
-
- Copyright: © 1999 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #pragma once
-
- #include "USB_ClassDriverAccess.h"
-
- enum
- {
- // Standard Command Opcodes
- kCmdFormat = 0x04,
- kCmdInquiry = 0x12,
- kCmdModeSelect = 0x55,
- kCmdModeSense6 = 0x1A,
- kCmdModeSense10 = 0x5A,
- kCmdPreventAllowRemoval = 0x1E,
- kCmdRead = 0x28,
- kCmdReadCapacity = 0x25,
- kCmdReadFormatCapacities = 0x23,
- kCmdRequestSense = 0x03,
- kCmdRezero = 0x01,
- kCmdSeek = 0x2B,
- kCmdSendDiagnostic = 0x1D,
- kCmdStartStopUnit = 0x1B,
- kCmdTestUnitReady = 0x00,
- kCmdWrite = 0x2A,
- kCmdWriteVerify = 0x2E,
- kCmdVerify = 0x2F
- };
-
- // Command set specifiers
- enum
- {
- kRBCCommand = 0,
- kSPCCommand
- };
-
- #pragma mark -
- #pragma mark Definitions for the Inquiry command
- // Inquiry Peripheral Qualifier
- enum
- {
- kInqPeripheralConnected = 0x00,
- kInqPeripheralSupportedButNotConnected = 0x20,
- kInqPeripheralNotSupported = 0x60,
- kInqPeripheralQualifierMask = 0xE0
- };
-
- // Inquiry Peripheral Device types
- enum
- {
- kInqDirectAccessSBCDevice = 0x00,
- kInqSequentialAccessSSCDevice = 0x01,
- kInqPrinterSSCDevice = 0x02,
- kInqProcessorSPCDevice = 0x03,
- kInqWriteOnceSBCDevice = 0x04,
- kInqCDROM_MMCDevice = 0x05,
- kInqScannerSCSI2Device = 0x06,
- kInqOpticalMemorySBCDevice = 0x07,
- kInqMediumChangerSMCDevice = 0x08,
- kInqCommunicationsSSCDevice = 0x09,
- /* 0x0A - 0x0B ASC IT8 Graphic Arts Prepress Devices */
- kInqStorageArrayControllerSCC2Device = 0x0C,
- kInqEnclosureServicesSESDevice = 0x0D,
- kInqSimplifiedDirectAccessRBCDevice = 0x0E,
- kInqOpticalCardReaderOCRWDevice = 0x0F,
- /* 0x10 - 0x1E Reserved Device Types */
- kInqUnknownOrNoDeviceType = 0x1F,
-
- kInqPeripheralDeviceTypeMask = 0x1F
- };
-
- // Inquiry Removable Bit Mask
- enum
- {
- kInqRemovableMask = 0x80,
- kInqANSIVersionMask = 0x07
- };
-
- //
- // Sizes for some of the inquiry data fields
- //
- enum
- {
- kVendorIDLen = 8,
- kProductIDLen = 16,
- kProductRevLen = 4
- };
-
- struct StandardInquiryData
- {
- UInt8 qualifierAndType; // 7-5 = Qualifier. 4-0 = Device type.
- UInt8 removableBit; // 7 = removable
- UInt8 version; // 7/6 = ISO/IEC, 5-3 = ECMA, 2-0 = ANSI.
- UInt8 responseData; // 7 = AERC, 6 = Obsolete, 5 = NormACA, 4 = HiSup 3-0 = Response data format.
- // If ANSI Version = 0, this is ATAPI and bits 7-4 = ATAPI version.
- UInt8 additionalLength; // Number of additional bytes available in inquiry data
- UInt8 SCCSReserved; // SCC-2 device flag and reserved fields
- UInt8 flags1; // First byte of support flags
- UInt8 flags2; // Second byte of support flags
- char vendorID[kVendorIDLen]; // Vendor ID in ascii
- char productID[kProductIDLen]; // Product ID in ascii
- char productRevision[kProductRevLen]; // Product revision in ascii
- };
- typedef struct StandardInquiryData StandardInquiryData;
- typedef StandardInquiryData* StandardInquiryDataPtr;
-
- #pragma mark -
- #pragma mark Definitions for the Mode Sense/Select commands
- // Values for PreventAllowRemoval command
- enum
- {
- kMode6ParameterHeaderLength = 0x04,
- kMode10ParameterHeaderLength = 0x08,
- kRBCDeviceParametersModePageCode = 0x06, // Per RBC
- kRBCDeviceParametersModePageLength = 0x0B, // Per RBC
-
- kAllModePages = 0x3F
- };
-
- #pragma mark -
- #pragma mark Definitions for the Prevent Allow Removal command
- // Values for PreventAllowRemoval command
- enum
- {
- kPreventMediaRemoval = true,
- kAllowMediaRemoval = false
- };
-
- #pragma mark -
- #pragma mark Definitions for the StartStop command
- // Values for StartStopEject command
- enum
- {
- kStartDevice = true,
- kStopDevice = false,
- kEjectMedia = true,
- kDontEjectMedia = false
- };
-
- #pragma mark -
- #pragma mark Definitions for the Read Capacity command
- typedef struct ReadCapacityData
- {
- UInt32 TotalBlocksOnMedia; // Total number of blocks
- UInt32 BlockLengthInBytes; // Block length in bytes
- } ReadCapacityData, *ReadCapacityDataPtr;
-
- #pragma mark -
- #pragma mark Definitions for the Request Sense command command
- // The Sense data that all devices should support
- enum
- {
- kSenseStandardDataSize = 18
- };
-
- #pragma mark -
- #pragma mark Prototypes for Command Builder Routines
- // ATAPI/SCSI-2 Device Commands used internally
- extern OSStatus ModeSenseBuilder( IntDriveRequestPBPtr requestPB, UInt8 CommandSet, UInt8 *Buffer, UInt8 modePage, UInt8 numBytes );
- extern OSStatus SendDiagnosticBuilder( IntDriveRequestPBPtr requestPB );
- extern OSStatus TestUnitReadyBuilder( IntDriveRequestPBPtr requestPB );
- extern OSStatus RequestSenseBuilder( IntDriveRequestPBPtr requestPB, Ptr senseData );
- extern OSStatus InquiryBuilder(IntDriveRequestPBPtr requestPB, UInt8 *Buffer, UInt8 InqDataLength);
- extern OSStatus GetMediaGeometryBuilder( IntDriveRequestPBPtr requestPB, ReadCapacityData *getGeometry );
- extern OSStatus ReadFormatCapacityBuilder( IntDriveRequestPBPtr requestPB, UInt8 *Buffer, UInt8 numBytes );
- extern OSStatus StartStopEjectCartridgeBuilder(IntDriveRequestPBPtr requestPB, Boolean StartDrive, Boolean doEject);
- extern OSStatus PreventAllowRemovalBuilder( IntDriveRequestPBPtr requestPB, Boolean preventRemoval );
- extern OSStatus FormatFloppyTrackBuilder( IntDriveRequestPBPtr requestPB, UInt8 *Buffer, UInt32 FormatCapacity, UInt16 blockSize, UInt8 TrackNum, UInt8 Side);
-
- // Routines used for processing data from the commands
- extern void FixRequestSenseData( IntDriveRequestPBPtr requestPB );
-